from recognizer import Recognizer
import tkinter as tk
rec = Recognizer()
window = tk.Tk()
window.title("Noun recognition")
window.geometry("400x380")
window.configure(bg='#E6E6FA')
l = tk.Label(
    window,
    relief="raised",
    justify="center",
    text="Welcome to our Noun Recognizer !",
    bg="crimson",
    fg="black",
    font=("Times New Roman",14,"bold"),
    width=40,
    height=2,
)
l.pack(anchor="center",side="top")
# 定义一个lable
l1 = tk.Label(
    window,
    relief="raised",
    text="Pleaese input the sentence !",
    bg="lightyellow",
    fg="black",
    font=("Times New Roman", 12),
    width=20,
    height=1,
)
l1.pack(anchor="center")
# 全局字符串变量
var1 = tk.StringVar()
# 定义输入内容的文本框
t1 = tk.Text(window, font=("楷体", 12), width=50, height=4)
t1.pack(anchor="center")
# 定义recognize按钮
def hit_recognize():
    list1.delete("0", "end")
    var1 = t1.get("0.0", "end")
    # 调用recognizer.py
    var = rec.analyse(var1)
    for item in var:
        list1.insert("end",item)
button_recognize = tk.Button(
    window,
    text="Recognize",
    width=6,
    height=1,
    command=hit_recognize,
    bg="lightgreen",
    font=("Times New Roman", 12),
)
button_recognize.pack(anchor="center")
# 输出处理结果的列表
list1 = tk.Listbox(window, width=24,selectmode="extended", font=("楷体", 12))
list1.pack(anchor="center")
# 定义quit按钮
def hit_quit():
    t1.delete("1.0", "end")
    var1.set("")
    list1.delete("0", "end")
button_quit = tk.Button(
    window,
    text="Quit",
    width=6,
    height=1,
    command=hit_quit,
    bg="lightgreen",
    font=("Times New Roman", 12),
)
button_quit.pack(anchor="center")
window.mainloop()
